<template>
  <div>
    <headerNav></headerNav>
    <div class="container">
      <router-view></router-view>
    </div>
    <!-- 只在指定路由显示全局导航栏 -->
    <footerNav v-if="showFooter"></footerNav>
  </div>
</template>
<script>
import footerNav from "@/components/footerNav.vue";
import headerNav from "@/components/headerNav.vue";
export default {
  components: {
    footerNav,
    headerNav
  },
  computed: {
    showFooter() {
      // 定义需要显示导航栏的路由名称（与router/index.js中配置的name一致）
      const allowRoutes = ['home', 'productList', 'forum', 'user'];
      // 返回当前路由是否在允许列表中
      return allowRoutes.includes(this.$route.name);
    }
  }
};
</script>